package org.ycy.data.generator.generator;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import org.ycy.data.generator.entity.NumberCheckInfo;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @ClassName RandomGenerator
 * @Description TODO
 * @Author 原长友
 * @Date 2023/3/5 22:56
 * @Version 1.0
 **/
public class NumberRandomGenerator extends IGenerator<NumberCheckInfo> {


    @Override
    public Object generator() {

        ThreadLocalRandom random = RandomUtil.getRandom();

        if (ObjectUtil.isNotEmpty(checkInfo)) {
            Integer max = (Integer) checkInfo.getMaxValue();
            Integer min = (Integer) checkInfo.getMinValue();
            return random.nextInt(max - min + 1) + min;
        }
        return random.nextInt();
    }
}
